<template>
  <div id="app">
    <v-header></v-header>
    <div class="content" :style="{ 'flex-basis': screenHeight }" ref="content">
      <!-- <div id="nav">
        <router-link to="/">Home</router-link> |
        <router-link to="/about">About</router-link>
      </div> -->
      <router-view />
    </div>

    <v-footer></v-footer>
  </div>
</template>
<script>
import header from "./components/Header.vue";
import footer from "./components/Footer.vue";
export default {
  data() {
    return {
      screenHeight: "",
    };
  },
  components: {
    "v-header": header,
    "v-footer": footer,
  },
  methods: {
    getScreenHeight() {
      this.screenHeight = window.innerHeight - 120 + "px";
    },
  },
  created() {
    window.addEventListener("resize", this.getScreenHeight);
    this.getScreenHeight();
    if (sessionStorage.getItem("store") ) {
      this.$store.replaceState(Object.assign({}, this.$store.state,JSON.parse(sessionStorage.getItem("store"))));
      sessionStorage.removeItem('store');
    }
    window.addEventListener("beforeunload",()=>{
      sessionStorage.setItem("store",JSON.stringify(this.$store.state))
    })
  },
  destroyed() {
    window.removeEventListener("resize", this.getScreenHeight);
  },
};
</script>
<style lang="scss">
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  height: 100%;
  display: flex;
  flex-direction: column;
  .header {
    flex: 0 0 70px;
  }
  .content {
    width:100%;
    overflow: auto;
  }
  .content::-webkit-scrollbar {
    width: 6px;
  }
  .content::-webkit-scrollbar-track-piece {
    background: #fff;
  }
  .content::-webkit-scrollbar-thumb {
    border-radius: 3px;
    -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.1);
    background: rgba(0, 0, 0, 0.1);
  }
  .scontent::-webkit-scrollbar-track {
    -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.1);
    border-radius: 0;
    background: rgba(0, 0, 0, 0.2);
  }
  .footer {
    flex: 0 0 50px;
  }
}

#nav {
  padding: 30px;
  text-align: center;
  a {
    font-weight: bold;
    color: #2c3e50;

    &.router-link-exact-active {
      color: #42b983;
    }
  }
}
</style>
